package com.ccys.common.third.gap;


import com.alibaba.fastjson.JSONObject;
import com.ccys.common.third.payPal.PayPalUtil;
import com.ccys.common.third.payPal.config.*;
import com.paypal.api.payments.Links;
import com.paypal.api.payments.Payment;
import com.paypal.base.rest.PayPalRESTException;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.junit.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Slf4j
@SpringBootTest
@RunWith(SpringJUnit4ClassRunner.class)
@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = {PayPalConstants.class})
public class GapUtilTest {

       /**
        * @description 测试 getMerchantTest
        * @date     2024/3/7
        * @author   cloud fly
        * 测试响应结果
       result={
       "code": "SGP-01-001",
       "data": {
       "best_combination": [
       34629
       ]
       },
       "message": "Success, Origin Response :  No merchant with all that products"
       }

        */
    @Test
    public  void getMerchantTest()  {
        Map<String,Object> param = new HashMap();
        Map<String,Object> buyer = new HashMap<>();
        Map<String,Object> recipient = new HashMap<>();
        Map<String,Object> address = new HashMap<>();
        Map<String,Object> consultation = new HashMap<>();

        /**
         {
         "buyer":{
         "email": "123@123.123",
         "name" : "123",
         "phone" : "41343154"
         },
         "recipient":{
         "name" : "123",
         "phone" : "41343154",
         "address:":{
         "address_full":"Jl. M.H. Thamrin No.30, Gondangdia, Kec. Menteng, Kota Jakarta Pusat, Daerah Khusus Ibukota Jakarta 10350 Indonesia",
         "latitude": "-6.274098",
         "longitude": "106.71",
         "postal_code":"12190"
         }
         },
         "products":[
         {
         "id":34629,
         "quantity":2
         }
         ],
         "best_combination":true,
         "similarmoleculeproduct":false,
         "multi_merchant":false,
         "no_range":true,
         "order_source":"WHC",
         "consultation":{
         "product_master_id" : 901330,
         "price":123.2
         }
         }
         */
        buyer.put("email","123@123.123");
        buyer.put("name","123");
        buyer.put("phone","41343154");
        param.put("buyer",buyer);
        recipient.put("name","123");
        recipient.put("phone","41343154");
        address.put("address_full", "Jl. M.H. Thamrin No.30, Gondangdia, Kec. Menteng, Kota Jakarta Pusat, Daerah Khusus Ibukota Jakarta 10350 Indonesia");
        address.put("latitude","-6.274098");
        address.put("longitude","106.71");
        address.put("postal_code","12190");
        recipient.put("address",address);
        param.put("recipient",recipient);
        List<JSONObject> products = new ArrayList<>();
        JSONObject product = new JSONObject();
        product.put("id",34629);
        product.put("quantity",2);
        products.add(product);
        param.put("products",products);
        param.put("best_combination",true);
        param.put("similarmoleculeproduct",false);
        param.put("multi_merchant",false);
        param.put("no_range",true);
        param.put("order_source","WHC");
        consultation.put("product_master_id",901330);
        consultation.put("price",123.2);
        param.put("consultation",consultation);
        String merchant = GapUtil.getMerchant(param);
        System.out.println("result=" + merchant);
    }
    @Test
    public  void getTest()  {
        //InitializingDeliveryInfo   构造 getMerchant 数据模型
        Integer invoiceId = null;
        String s = invoiceId + "";
        System.out.println("result=" + s);
    }






}
